<?php
/**
 * Created by PhpStorm.
 * User: yuyiwen
 * Date: 2018/9/20
 * Time: 下午5:14
 */

namespace app\index\controller;


class User  extends Common
{
        public function _initialize()
        {
            parent::_initialize();
            $id = session('id');
            $userInfo = db('member')->find($id);
            $this->assign('userInfo' , $userInfo);
        }

    public function user ()
        {
            return view();
        }

        public function myqrcode ()
        {
            $id = session('id');
            $key = md5($id.'435ey6rftygubhj kl87i6trhfg');
//        $text = url('log/login' , ['id'=>$id , 'key'=>$key] , true , true );
            $text = 'http://192.168.1.167'.url('log/login' , ['id'=>$id , 'key'=>$key] );

            $this->assign('text' , $text);
            return view();
        }

        public function myuser ()
        {
            return view();
        }

    public function partners ()
    {
        # 获取当前用户id
        $current_id = session('id');
        # 调用会员模型
        $member = model('Member');
        # 获取三级会员数据
        $SonMember = $member->getSonMember ($current_id);
//        dump($SonMember);die;
        # 重组三级会员数组
        $levelMember = $member->getLevelMember($SonMember);


        $this->assign('levelMember' , $levelMember);

        return view();
    }

    public function upgrade2business ()
    {
        return view();
    }

    public function qrcode ()
    {
        vendor('phpqrcode.phpqrcode');
        $id = session('id');
        $key = md5($id.'435ey6rftygubhj kl87i6trhfg');
//        $text = url('log/login' , ['id'=>$id , 'key'=>$key] , true , true );
        $text = 'http://192.168.1.167'.url('log/login' , ['id'=>$id , 'key'=>$key] );
        $qrcode = new \QRcode();
        $qrcode->png($text , false , 'L' , 4 , 2);
        exit;
    }
}